package com.dingup.api.enums;

import com.dingup.api.model.sys.SysDept;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by wancheng on 2018/8/7.
 */
public enum  StudentCampusEnum {
    SHANGHAI(56008995L,"上海校区"),
    NANJING(56008994L,"南京校区"),
    YUEDUZU(65033357L,"阅读组"),
    SHUXUEZU(65128545L,"数学组");

    public static SysDept getAllowDept(SysDept dept){
        SysDept res = null;
        for (StudentCampusEnum e:StudentCampusEnum.values()) {
            if (  dept.getId().equals(e.getId()) ||  dept.getParentId().equals(e.getId())){
                res = new SysDept();
                res.setId(e.getId());
                res.setName(e.getName());
                break;
            }
        }
        return res;
    }
    public static List<StudentCampusEnum> getAll(){
        List<StudentCampusEnum> list = new ArrayList<>();
        for (StudentCampusEnum e:StudentCampusEnum.values()) {
            list.add(e);
        }
        return list;
    }
    public static Map<String,Object> getMap(String campusId){
        Map<String,Object> map = new HashMap();
        for (StudentCampusEnum e: StudentCampusEnum.values()) {
            if (e.getId().equals(Long.valueOf(campusId))){
                map.put("id",e.getId());
                map.put("name",e.getName());
                break;
            }
        }
        return map;
    }
    public static String getName(String campusId){
        String name = null;
        for (StudentCampusEnum e: StudentCampusEnum.values()) {
            if (e.getId().equals(Long.valueOf(campusId))){
                name = e.getName();
                break;
            }
        }
        return name;
    }
    public static StudentCampusEnum getEnum(String campusId){
        StudentCampusEnum res = null;
        for (StudentCampusEnum e: StudentCampusEnum.values()) {
            if (e.getId().equals(Long.valueOf(campusId))){
                res = e;
                break;
            }
        }
        return res;
    }
    private Long id;

    private String name;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    StudentCampusEnum(Long id, String name) {
        this.id = id;
        this.name = name;
    }
}
